package jp.aist.gtrc.plus.admission.EDF;

import java.util.*;

public class TestRecommend {
   public static int numOfCPUs = 2;

   public static void main(String[] args) throws Exception {
      Set<CPU> cpus = new HashSet<CPU>();
      for (int i=0; i < numOfCPUs; i++) {
         cpus.add(new CPU(i));  
      }     

      EDFAdmission admission = new EDFAdmission(); 

      ArrayList<JobArray> jobArrays = new ArrayList<JobArray>();
      jobArrays.add(new JobArray("1",4,1,3));
      jobArrays.add(new JobArray("2",2,2,4));
      jobArrays.add(new JobArray("3",6,1,8));
      jobArrays.add(new JobArray("4",2,1,8));
      //JobArray jobArray = new JobArray("5",8,1,17);
      JobArray jobArray = new JobArray("5",2,1,1);

      System.out.println(admission.testAndRecommend(cpus,getJobs(jobArrays),jobArray));  
      jobArrays.add(jobArray);
      cpus = new HashSet<CPU>();
      for (int i=0; i < numOfCPUs; i++) {
         cpus.add(new CPU(i));  
      }     
      System.out.println(admission.test(cpus,getJobs(jobArrays)));  
   }

   public static Collection<Job> getJobs(Collection<JobArray> jobArrays) {
      int id = 0;
      ArrayList<Job> jobs = new ArrayList<Job>();
      for (JobArray jobArray : jobArrays) {
         for (int i=0; i < jobArray.numOfJobs; i++) {
            Job job = new Job(id,jobArray.name+"/"+i,jobArray.exeTime,jobArray.deadline);
            jobs.add(job);
            id++;
         }
      }
      return jobs;
   }



}
